package com.holly.unit.system.modular.organization.controller;

import com.holly.unit.core.pojo.request.BaseRequest;
import com.holly.unit.core.pojo.response.ResponseData;
import com.holly.unit.core.pojo.response.SuccessResponseData;
import com.holly.unit.scanner.api.annotation.ApiResource;
import com.holly.unit.scanner.api.annotation.GetResource;
import com.holly.unit.scanner.api.annotation.PostResource;
import com.holly.unit.system.api.pojo.organization.HrPositionRequest;
import com.holly.unit.system.modular.organization.entity.HrPosition;
import com.holly.unit.system.modular.organization.service.HrPositionService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

/**
 * 系统岗位控制器
 *
 * @author holly
 * @date 2020/11/18 21:56
 */
@RestController
@ApiResource(name = "系统岗位管理")
@Api(tags = "系统岗位管理")
public class HrPositionController {

    @Resource
    private HrPositionService hrPositionService;

    /**
     * 添加系统岗位
     *
     * @author holly
     * @date 2020/11/04 11:07
     */
    @ApiOperation(value = "添加系统岗位" ,notes = "添加系统岗位")
    @PostResource(name = "添加系统岗位", path = "/hrPosition/add")
    public ResponseData add(@RequestBody @Validated(HrPositionRequest.add.class) HrPositionRequest hrPositionRequest) {
        hrPositionService.add(hrPositionRequest);
        return new SuccessResponseData();
    }

    /**
     * 删除系统岗位
     *
     * @author holly
     * @date 2020/11/04 11:07
     */
    @ApiOperation(value = "删除系统岗位" ,notes = "删除系统岗位")
    @PostResource(name = "删除系统岗位", path = "/hrPosition/delete")
    public ResponseData delete(@RequestBody @Validated(HrPositionRequest.delete.class) HrPositionRequest hrPositionRequest) {
        hrPositionService.del(hrPositionRequest);
        return new SuccessResponseData();
    }

    /**
     * 批量删除系统岗位
     *
     * @author holly
     * @date 2021/4/8 13:50
     */
    @ApiOperation(value = "批量删除系统岗位" ,notes = "批量删除系统岗位")
    @PostResource(name = "批量删除系统岗位", path = "/hrPosition/batchDelete")
    public ResponseData batchDelete(@RequestBody @Validated(HrPositionRequest.batchDelete.class) HrPositionRequest hrPositionRequest) {
        hrPositionService.batchDel(hrPositionRequest);
        return new SuccessResponseData();
    }

    /**
     * 编辑系统岗位
     *
     * @author holly
     * @date 2020/11/04 11:07
     */
    @ApiOperation(value = "编辑系统岗位" ,notes = "编辑系统岗位")
    @PostResource(name = "编辑系统岗位", path = "/hrPosition/edit")
    public ResponseData edit(@RequestBody @Validated(HrPositionRequest.edit.class) HrPositionRequest hrPositionRequest) {
        hrPositionService.edit(hrPositionRequest);
        return new SuccessResponseData();
    }

    /**
     * 更新岗位状态
     *
     * @author holly
     * @date 2020/11/04 11:07
     */
    @ApiOperation(value = "更新岗位状态" ,notes = "更新岗位状态")
    @PostResource(name = "更新岗位状态", path = "/hrPosition/updateStatus")
    public ResponseData updateStatus(@RequestBody @Validated(BaseRequest.updateStatus.class) HrPositionRequest hrPositionRequest) {
        hrPositionService.changeStatus(hrPositionRequest);
        return new SuccessResponseData();
    }

    /**
     * 查看详情系统岗位
     *
     * @author holly
     * @date 2020/11/04 11:07
     */
    @ApiOperation(value = "查看详情系统岗位" ,notes = "查看详情系统岗位")
    @GetResource(name = "查看详情系统岗位", path = "/hrPosition/detail", responseClass = HrPosition.class)
    public ResponseData detail(@Validated(HrPositionRequest.detail.class) HrPositionRequest hrPositionRequest) {
        return new SuccessResponseData(hrPositionService.detail(hrPositionRequest));
    }

    /**
     * 分页查询系统岗位
     *
     * @author holly
     * @date 2020/11/04 11:07
     */
    @ApiOperation(value = "分页查询系统岗位" ,notes = "分页查询系统岗位")
    @GetResource(name = "分页查询系统岗位", path = "/hrPosition/page", responseClass = HrPosition.class)
    public ResponseData page(HrPositionRequest hrPositionRequest) {
        return new SuccessResponseData(hrPositionService.findPage(hrPositionRequest));
    }

    /**
     * 获取全部系统岗位
     *
     * @author holly
     * @date 2020/11/04 11:07
     */
    @ApiOperation(value = "获取全部系统岗位" ,notes = "获取全部系统岗位")
    @GetResource(name = "获取全部系统岗位", path = "/hrPosition/list", responseClass = HrPosition.class)
    public ResponseData list(HrPositionRequest hrPositionRequest) {
        return new SuccessResponseData(hrPositionService.findList(hrPositionRequest));
    }

}
